package com.orange.quickback.system.entities.user.manage;

import com.orange.quickback.system.entities.QBootObject;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "q_boot_user")
@Data
public class QBootUser extends QBootObject implements Serializable {
    @Column(name = "user_name", unique = true, nullable = false)
    private String userName;
    @Column(name = "nick_name", nullable = false)
    private String nickName;
    @Column(name = "e_mail", nullable = false, unique = true)
    private String eMail;
    @Column(name = "password", nullable = false, length = 512)
    private String password;
    @Column(name = "phone_number", nullable = false, length = 256)
    private String phoneNumber;
    @Column(name = "enabled")
    private Boolean enabled;
    @Column(name = "locked")
    private Boolean locked;

    @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
    @JoinTable(
            name = "q_boot_user_role",
            joinColumns = {
            @JoinColumn(name = "user_id",referencedColumnName="id") },
            inverseJoinColumns = {
            @JoinColumn(name = "role_id",referencedColumnName="id") })
    List<QBootRole> role_users;
    @OneToOne(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY)
    @JoinColumn(name = "id",referencedColumnName = "id")
    QBootUserInfo qBootUserInfo;
}
